<?php use_helper('I18N') ?>

<?php echo form_tag('structure/list', array('id' => 'frmlist', 'name' => 'frmlist')) ?>

<style type="text/css">
/*Style sheet used for demo. Remove if desired*/
.handcursor{
cursor:hand;
cursor:pointer;
}
</style>

<script>
function openImageWindow(name){
    var params  = 'width=320';
    params += ', height=460';
    params += ', top=0, left=0';
    //params += ', fullscreen=yes';

    newwin = window.open("http://<?php echo $_SERVER['HTTP_HOST']; ?>/uploads/"+name,'image', params);
    if (window.focus)
    {
        newwin.focus();
    }
}

function openWebsiteWindow(url){
    var params  = 'width=320';
    params += ', height=460';
    params += ', top=0, left=0';

    newwin = window.open("http://"+url,'website', params);
    if (window.focus)
    {
        newwin.focus();
    }
}
</script>

<table width="950">
	<tr>
    	<td valign="top">
        	<table width="100%">
            	<tr>
                	<td align="left" class="welcome">WELCOME <?php echo $_SESSION['user_name']; ?></td>
                    <td width="16">&nbsp;</td>
                    <td width="164"></td>
                    <td width="70" align="right" valign="bottom"><img name="btnLogout" id="btnLogout" onmouseover="roll_over('btnLogout', '/images/logout_btnAF.jpg')" onmouseout="roll_over('btnLogout', '/images/logout_btn.jpg')" src="/images/logout_btn.jpg" border="0" onClick="location.href='/user/logout'" /></td>
                </tr>
                <tr>
                	<td colspan="4">
<?php echo link_to('User List','user/list') ?>&nbsp;&nbsp;&nbsp;
<?php echo link_to('Structure','structure/list') ?>&nbsp;&nbsp;&nbsp;
<?php echo link_to('CSS','structure/css') ?>&nbsp;&nbsp;&nbsp;
<?php echo link_to('Google Analytic','structure/ganalytic') ?>&nbsp;&nbsp;&nbsp;
<?php echo link_to('Share Script','structure/sharescript') ?>&nbsp;&nbsp;&nbsp;
<?php echo link_to('Landing Page Title','structure/landingtitle') ?>
                	</td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
    	<td align="right"><?php echo button_to('New Structure 1','/structure/firstedit') ?>&nbsp;<?php echo button_to('New Structure 2','/structure/secondedit') ?>&nbsp;<?php echo button_to('New Structure 3','/structure/thirdedit') ?>&nbsp;<?php echo button_to('New Structure 4','/structure/fourthedit') ?></td>
    </tr>
    <tr>
    	<td><div id="pm_ex_list" name="pm_ex_list">
        	

                <?php
					echo '<table class="admin" width="100%" cellpadding="0" cellspacing="0">';
					//echo '<tr><td align="left" class="adminTitle" height="40">&nbsp;Structure 1</td></tr>';
					echo '<tr><td class="adminTitle">';					
					echo '<table width="100%"><tr>';
					echo '<td width="22"></td>';
                    echo '<td width="400" align="left">Level 1</td>';
                    echo '<td width="85" align="left">Sequence</td>';
                    echo '<td width="100" align="left" valign="middle"></td>';
                    echo '<td width="100" align="left" valign="middle"></td>';
                    echo '<td width="66" align="left" valign="middle"></td>';
                    echo '<td width="66" align="left" valign="middle"></td>';
                    echo '</tr></table>';
                    echo '</td></tr>';
					
					$color = "#cfecdb";
					
					foreach ($tbl_structures as $tbl_structure){
						echo '<tr><td bgcolor="'.$color.'">';
						echo '<table width="100%"><tr>';
						echo '<td width="22"><div id="bobcontent'.$tbl_structure->getFId().'-title" class="handcursor"></div></td>';
                        echo '<td width="400" align="left">'.$tbl_structure->getFName().'</td>';
                        echo '<td width="85" align="left">'.$tbl_structure->getFSeqNo().'</td>';
                        if($tbl_structure->getFContent()<>"" || $tbl_structure->getFIcon()<>"" || $tbl_structure->getFImage()<>"")
                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/landing?article='.$tbl_structure->getFId().'\');">View Live</a></td>';
                        else
                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Live</td>';
                        if($tbl_structure->getFContentDraft()<>"" || $tbl_structure->getFIconDraft()<>"" || $tbl_structure->getFImageDraft()<>"")
                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/landingDraft?article='.$tbl_structure->getFId().'\');">View Draft</a></td>';
                        else
                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Draft</td>';
                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_edit.png" />&nbsp;<a href="'.url_for('/structure/firstedit?f_id='.$tbl_structure->getFId()).'" class="login">edit</a></td>';
                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_close.png" />&nbsp;'.link_to('delete','structure/delete?f_structure=1&f_id='.$tbl_structure->getFId(), array('class'=>'login', 'post'=>'true', 'confirm'=>'Are you sure you want to delete?')).'</td>';
                      	echo '</tr></table>';
                       	echo '</td></tr>';
                            	
                      	if($color=="#cfecdb")
                      		$color="#ffffff";
                       	else
                       		$color = "#cfecdb";
						
						$c = new Criteria();
						$c->add(TblStructurePeer::F_PARENTID, $tbl_structure->getFId());
						$c->addAnd(TblStructurePeer::F_STATUS, 'active');
						$c->addAscendingOrderByColumn(TblStructurePeer::F_SEQ_NO);
						$rs_second = TblStructurePeer::doSelect($c);
																		
						//level 2 title
						if($rs_second){
							echo '<tr><td><div id="bobcontent'.$tbl_structure->getFId().'" class="switchgroup1">';
							echo '<table class="admin" width="100%" cellpadding="0" cellspacing="0">';
							echo '<tr><td align="left" class="adminTitle" height="40">&nbsp;'.$tbl_structure->getFName().' (Level 2)</td></tr>';
							echo '<tr><td class="adminTitle">';
							echo '<table width="100%"><tr>';
							echo '<td width="22"></td>';
		                    echo '<td width="200" align="left">Level 1</td>';
		                    echo '<td width="200" align="left">Level 2</td>';
		                    echo '<td width="85" align="left">Sequence</td>';
		                    echo '<td width="100" align="left" valign="middle"></td>';
		                    echo '<td width="100" align="left" valign="middle"></td>';
		                    echo '<td width="66" align="left" valign="middle"></td>';
		                    echo '<td width="66" align="left" valign="middle"></td>';
		                    echo '</tr></table>';
		                    echo '</td></tr>';
		                    
							$color2 = "#cfecdb";
						}
						
						foreach($rs_second as $second){
							echo '<tr><td bgcolor="'.$color2.'">';
							echo '<table width="100%"><tr>';
							echo '<td width="22"><div id="bobcontent'.$second->getFId().'-title" class="handcursor"></div></td>';
							echo '<td width="200" align="left">'.$tbl_structure->getFName().'</td>';
	                        echo '<td width="200" align="left">'.$second->getFName().'</td>';
	                        echo '<td width="85" align="left">'.$second->getFSeqNo().'</td>';	                        
	                        if($second->getFContent()<>"" || $second->getFIcon()<>"" || $second->getFImage()<>"")
	                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/article?articleId='.$second->getFId().'\');">View Live</a></td>';
	                        else
	                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Live</td>';
                        	if($second->getFContentDraft()<>"" || $second->getFIconDraft()<>"" || $second->getFImageDraft()<>"")
	                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/articleDraft?articleId='.$second->getFId().'\');">View Draft</a></td>';
	                        else
	                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Draft</td>';
	                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_edit.png" />&nbsp;<a href="'.url_for('/structure/secondedit?f_id='.$second->getFId()).'" class="login">edit</a></td>';
	                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_close.png" />&nbsp;'.link_to('delete','structure/delete?f_structure=2&f_id='.$second->getFId(), array('class'=>'login', 'post'=>'true', 'confirm'=>'Are you sure you want to delete?')).'</td>';
	                      	echo '</tr></table>';
	                       	echo '</td></tr>';
	                            	
	                      	if($color2=="#cfecdb")
	                      		$color2="#ffffff";
	                       	else
	                       		$color2 = "#cfecdb";
							
							$c = new Criteria();
							$c->add(TblStructurePeer::F_PARENTID, $second->getFId());
							$c->addAnd(TblStructurePeer::F_STATUS, 'active');
							$c->addAscendingOrderByColumn(TblStructurePeer::F_SEQ_NO);
							$rs_third = TblStructurePeer::doSelect($c);
							
							//level 3 title
							if($rs_third){
								echo '<tr><td><div id="bobcontent'.$second->getFId().'" class="switchgroup1">';
								echo '<table class="admin" width="100%" cellpadding="0" cellspacing="0">';
								echo '<tr><td align="left" class="adminTitle" height="40">&nbsp;'.$second->getFName().' (Level 3)</td></tr>';
								echo '<tr><td class="adminTitle">';
								echo '<table width="100%"><tr>';
								echo '<td width="22"></td>';
			                    echo '<td width="150" align="left">Level 1</td>';
			                    echo '<td width="150" align="left">Level 2</td>';
			                    echo '<td width="150" align="left">Level 3</td>';
			                    echo '<td width="85" align="left">Sequence</td>';
			                    echo '<td width="100" align="left" valign="middle"></td>';
			                    echo '<td width="100" align="left" valign="middle"></td>';
			                    echo '<td width="66" align="left" valign="middle"></td>';
			                    echo '<td width="66" align="left" valign="middle"></td>';
			                    echo '</tr></table>';
			                    echo '</td></tr>';			                    
			                    	
			                    $color3 = "#cfecdb";
							}
							
							foreach($rs_third as $third){
								echo '<tr><td bgcolor="'.$color3.'">';
								echo '<table width="100%"><tr>';
								echo '<td width="22"><div id="bobcontent'.$third->getFId().'-title" class="handcursor"></div></td>';
								echo '<td width="150" align="left">'.$tbl_structure->getFName().'</td>';
								echo '<td width="150" align="left">'.$second->getFName().'</td>';
		                        echo '<td width="150" align="left">'.$third->getFName().'</td>';
		                        //echo '<td width="400" align="left">'.$third->getFLink().'</td>';
		                        //if($third->getFImage()<>"")
		                        //	echo '<td width="100" align="left"><a href="javascript:openImageWindow(\''.$third->getFImage().'\');">View</a></td>';
		                        //else
		                        //	echo '<td width="100" align="left">View</td>';
		                        echo '<td width="85" align="left">'.$third->getFSeqNo().'</td>';
		                        if($third->getFContent()<>"" || $third->getFIcon()<>"" || $third->getFImage()<>"")
		                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/article?articleId='.$third->getFId().'\');">View Live</a></td>';
		                        else
		                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Live</td>';
		                        if($third->getFContentDraft()<>"" || $third->getFIconDraft()<>"" || $third->getFImageDraft()<>"")
		                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/articleDraft?articleId='.$third->getFId().'\');">View Draft</a></td>';
		                        else
		                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Draft</td>';
		                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_edit.png" />&nbsp;<a href="'.url_for('/structure/thirdedit?f_id='.$third->getFId()).'" class="login">edit</a></td>';
		                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_close.png" />&nbsp;'.link_to('delete','structure/delete?f_structure=3&f_id='.$third->getFId(), array('class'=>'login', 'post'=>'true', 'confirm'=>'Are you sure you want to delete?')).'</td>';
		                      	echo '</tr></table>';
		                       	echo '</td></tr>';
		                            	
		                      	if($color3=="#cfecdb")
		                      		$color3="#ffffff";
		                       	else
		                       		$color3 = "#cfecdb";
								
								
								$c = new Criteria();
								$c->add(TblStructurePeer::F_PARENTID, $third->getFId());
								$c->addAnd(TblStructurePeer::F_STATUS, 'active');
								$c->addAscendingOrderByColumn(TblStructurePeer::F_SEQ_NO);
								$rs_fourth = TblStructurePeer::doSelect($c);
								
								//level 4 title
								if($rs_fourth){
									echo '<tr><td><div id="bobcontent'.$third->getFId().'" class="switchgroup1">';
									echo '<table class="admin" width="100%" cellpadding="0" cellspacing="0">';
            						echo '<tr><td align="left" class="adminTitle" height="40">&nbsp;'.$third->getFName().' (Level 4)</td></tr>';
									
									echo '<tr><td class="adminTitle">';
									echo '<table width="100%"><tr>';
				                    echo '<td width="150" align="left">Level 1</td>';
				                    echo '<td width="150" align="left">Level 2</td>';
				                    echo '<td width="150" align="left">Level 3</td>';
				                    echo '<td width="150" align="left">Level 4</td>';
				                    //echo '<td width="400" align="left">Favorite Link</td>';
				                    //echo '<td width="100" align="left">Background</td>';
				                    echo '<td width="85" align="left">Sequence</td>';
				                    echo '<td width="100" align="left" valign="middle"></td>';
				                    echo '<td width="100" align="left" valign="middle"></td>';
				                    echo '<td width="66" align="left" valign="middle"></td>';
				                    echo '<td width="66" align="left" valign="middle"></td>';
				                    echo '</tr></table>';
			                    	echo '</td></tr>';
			                    	
			                    	$color4 = "#cfecdb";
								}
								
								foreach($rs_fourth as $fourth){
									echo '<tr><td bgcolor="'.$color4.'">';
									echo '<table width="100%"><tr>';
									echo '<td width="150" align="left">'.$tbl_structure->getFName().'</td>';
									echo '<td width="150" align="left">'.$second->getFName().'</td>';
									echo '<td width="150" align="left">'.$third->getFName().'</td>';
			                        echo '<td width="150" align="left">'.$fourth->getFName().'</td>';
			                        //echo '<td width="400" align="left">'.$fourth->getFLink().'</td>';
			                        //if($fourth->getFImage()<>"")
			                        //	echo '<td width="100" align="left"><a href="javascript:openImageWindow(\''.$fourth->getFImage().'\');">View</a></td>';
			                        //else
			                        //	echo '<td width="100" align="left">View</td>';
			                        echo '<td width="85" align="left">'.$fourth->getFSeqNo().'</td>';
			                        if($fourth->getFContent()<>"" || $fourth->getFIcon()<>"" || $fourth->getFImage()<>"")
			                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/article?articleId='.$fourth->getFId().'\');">View Live</a></td>';
			                        else
			                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Live</td>';		                        
			                        if($fourth->getFContentDraft()<>"" || $fourth->getFIconDraft()<>"" || $fourth->getFImageDraft()<>"")
			                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;<a href="javascript:openWebsiteWindow(\'mobile.taylors.edu.my/m/articleDraft?articleId='.$fourth->getFId().'\');">View Draft</a></td>';
			                        else
			                        	echo '<td width="100" align="left"><img src="/images/icon_edit.png" />&nbsp;View Draft</td>';
			                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_edit.png" />&nbsp;<a href="'.url_for('/structure/fourthedit?f_id='.$fourth->getFId()).'" class="login">edit</a></td>';
			                        echo '<td width="66" align="left" valign="middle"><img src="/images/icon_close.png" />&nbsp;'.link_to('delete','structure/delete?f_structure=4&f_id='.$fourth->getFId(), array('class'=>'login', 'post'=>'true', 'confirm'=>'Are you sure you want to delete?')).'</td>';
			                      	echo '</tr></table>';
			                       	echo '</td></tr>';
			                            	
			                      	if($color4=="#cfecdb")
			                      		$color4="#ffffff";
			                       	else
			                       		$color4 = "#cfecdb";
								}
								
								if($rs_fourth){
									echo '</div></td></tr>';
									echo '</table>';
								}
							}							
							
							if($rs_third){
								echo '</div></td></tr>';
								echo '</table>';
							}							
						}				
						
						if($rs_second){
							echo '</div></td></tr>';
							echo '</table><br><br>';
						}
						
					}
					
					echo '</table>';
				?>            
            </div>
        </td>
    </tr>
</table>

<script src="http://mobile.taylors.edu.my/switchcontent.js" type="text/javascript"></script>

<script type="text/javascript">
// MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
// Call Instance.init() at the very end. REQUIRED

var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
bobexample.setStatus('<img src="/images/collapse.jpg" /> ', '<img src="/images/expand.jpg" /> ')
bobexample.setColor('darkred', 'grey')
bobexample.setPersist(true)
bobexample.collapsePrevious(false) //Only one content open at any given time
bobexample.init()
</script>


</form>
